{extend name='admin@public/content'}

{block name="content"}
<div class="row">
	<div class="col-xs-12">
			<form autocomplete="off" class="layui-form layui-box" action="{:url('saveConfig')}" data-auto="true" method="post">
				{empty name="custom_config"}
					{foreach name="data['config']" item="form" key="o_key"}
						<div class="form-group">
							<label>
								{$form.title|default=''}
								{present name="form.tip"}
									<span class="check-tips">{$form.tip}</span>
								{/present}
							</label>
							<div class="controls layui-form">
								{switch name="form.type"}
									{case value="text"}
										<input type="text" name="config[{$o_key}]" class="layui-input" value="{$form.value}">
									{/case}
									{case value="password"}
										<input type="password" name="config[{$o_key}]" class="layui-input" value="{$form.value}">
									{/case}
									{case value="hidden"}
										<input type="hidden" name="config[{$o_key}]" value="{$form.value}">
									{/case}
									{case value="radio"}
										{foreach name="form.options" item="opt" key="opt_k"}
											<label>
												<input class="flat-red" title="{$opt}" type="radio" name="config[{$o_key}]" value="{$opt_k}" {eq name="form.value" value="$opt_k"} checked{/eq}>
											</label>
										{/foreach}
									{/case}
									{case value="checkbox"}
										{foreach name="form.options" item="opt" key="opt_k"}
											<label>
												{php}
													is_null($form["value"]) && $form["value"] = array();
												{/php}
												<input class="flat-red" title="{$opt}" type="checkbox" name="config[{$o_key}][]" value="{$opt_k}" {in name="opt_k" value="$form.value"} checked{/in}>{$opt}
											</label>
										{/foreach}
									{/case}
									{case value="select"}
										<select class="form-control" name="config[{$o_key}]">
											{foreach name="form.options" item="opt" key="opt_k"}
												<option value="{$opt_k}" {eq name="form.value" value="$opt_k"} selected{/eq}>{$opt}</option>
											{/foreach}
										</select>
									{/case}
									{case value="textarea"}
										<label class="textarea">
											<textarea name="config[{$o_key}]">{$form.value}</textarea>
										</label>
									{/case}
									{case value="picture_union"}

									{/case}
									{case value="group"}
										<ul class="tab-nav nav nav-tabs">
											{volist name="form.options" id="li"}
												<li data-tab="tab{$i}" {eq name="i" value="1"}class="current"{/eq}><a href="javascript:void(0);">{$li.title}</a></li>
											{/volist}
										</ul>
										<div class="two-tab-content">
											{volist name="form.options" id="tab"}
												<div id="tab{$i}" class="tab-pane {eq name="i" value="1"}in{/eq} tab{$i}">
													{foreach name="tab['options']" item="tab_form" key="o_tab_key"}
													<label class="item-label">
														{$tab_form.title|default=''}
														{present name="tab_form.tip"}
															<span class="check-tips">{$tab_form.tip}</span>
														{/present}
													</label>
													<div class="controls">
														{switch name="tab_form.type"}
															{case value="text"}
																<input type="text" name="config[{$o_tab_key}]" class="text input-large" value="{$tab_form.value}">
															{/case}
															{case value="password"}
																<input type="password" name="config[{$o_tab_key}]" class="text input-large" value="{$tab_form.value}">
															{/case}
															{case value="hidden"}
																<input type="hidden" name="config[{$o_tab_key}]" value="{$tab_form.value}">
															{/case}
															{case value="radio"}
																{foreach name="tab_form.options" item="opt" key="opt_k"}
																	<label class="radio">
																		<input type="radio" name="config[{$o_tab_key}]" value="{$opt_k}" {eq name="tab_form.value" value="$opt_k"} checked{/eq}>{$opt}
																	</label>
																{/foreach}
															{/case}
															{case value="checkbox"}
																{foreach name="tab_form.options" item="opt" key="opt_k"}
																	<label class="checkbox">
																		{php} is_null($tab_form["value"]) && $tab_form["value"] = array();{/php}
																		<input type="checkbox" name="config[{$o_tab_key}][]" value="{$opt_k}" {in name="opt_k" value="$tab_form.value"} checked{/in}>{$opt}
																	</label>
																{/foreach}
															{/case}
															{case value="select"}
																<select name="config[{$o_tab_key}]">
																	{foreach name="tab_form.options" item="opt" key="opt_k"}
																		<option value="{$opt_k}" {eq name="tab_form.value" value="$opt_k"} selected{/eq}>{$opt}</option>
																	{/foreach}
																</select>
															{/case}
															{case value="textarea"}
																<label class="textarea input-large">
																	<textarea name="config[{$o_tab_key}]">{$tab_form.value}</textarea>
																</label>
															{/case}
															{case value="picture_union"}

															{/case}
															{/switch}
														</div>
													{/foreach}
												</div>
											{/volist}
										</div>
									{/case}
								{/switch}
							</div>
						</div>
					{/foreach}
				{else /}
					{present name="custom_config"}
						{$custom_config}
					{/present}
				{/empty}
				<input type="hidden" name="id" value="{:input('id')}" readonly>
				<div class="btn-submit-group  text-center">
					<button class="layui-btn" type='submit'>保存数据</button>
					<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-back>取消编辑</button>
				</div>
			</form>
	</div>
</div>
<script>
    (function () {
        var form = layui.form;
        form.render();
    })();
</script>
{/block}
